<template>
    <view class="pd pt60 pm120 bgtmert">
    	<view class="formrow">
    		<view class="z9 fz28">
    			名称
    		</view>
    		<view class="mt20 pr">
    			<input type="text" placeholder="请输入名称" class="jhhgerttyt" v-model="form.name"/>
    		</view>
    	</view>
		
		<view class="formrow mt70">
			<view class="z9 fz28">
				组织性质
			</view>
			<view class="mt20 pr jhhgerttyt">
				<picker mode="selector" :range="rangea" @change="ddffgrb">
					<view>
					<text class="z9" v-if="jhghggsd<0">
							请选择组织性质
					</text>	
					<text v-else>
						{{rangea[jhghggsd]}}
					</text>
					</view>
				</picker>
				<uni-icons type="down" color="#8F9097" class="kjnnjxeert"></uni-icons>
			</view>
		</view>
		
		<view class="formrow mt70">
			<view class="z9 fz28">
				规模
			</view>
			<view class="mt20 pr jhhgerttyt">
				<picker mode="selector" :range="rangeb" @change="ddffgrbb">
					<view>
					<text class="z9" v-if="jhghggsdb<0">
							请选择规模
					</text>	
					<text v-else>
						{{rangeb[jhghggsdb]}}
					</text>
					</view>
				</picker>
				<uni-icons type="down" color="#8F9097" class="kjnnjxeert"></uni-icons>
			</view>
		</view>
		
		
		<view class="formrow mt70">
			<view class="z9 fz28">
				地区
			</view>
			<navigator url='/pages/user/userinfo/region' class="mt20 pr jhhgerttyt">
				<text v-if="addresss.province">
						{{addresss.province}}-{{addresss.city}}-{{addresss.area}}
				</text>	
				<text v-else>
					{{form.region}}
				</text>
				<uni-icons type="down" color="#8F9097" class="kjnnjxeert"></uni-icons>
			</navigator>
		</view>
		
		<view class="formrow mt70">
			<view class="z9 fz28">
				我的职务
			</view>
			<view class="mt20 pr">
				<input type="text" placeholder="请输入我的职务" class="jhhgerttyt" v-model="form.job_title"/>
			</view>
		</view>
		<uni-list  class="mt70">
			<uni-list-item title="组织管理" @tap="hf('/pages/user/MyOrganization/management?id='+id)"></uni-list-item>
		</uni-list>
    </view>
</template>
<script>
    export default {
        data() {
            return {
				jhghggsd:-1,
				rangea:['组织性质','组织性质2'],
				jhghggsdb:-1,
				rangeb:['0-50','100-200','200-300'],
				id:"",
				form:""	,
				addresss:{
					province:'',
					city:'',
					area:''
				}
			}
        },
        components: {},
        methods: {
			ddffgrb(e){
				this.jhghggsd = e.detail.value
				this.form.nature=e.detail.value
			},
			ddffgrbb(e){
				this.jhghggsdb = e.detail.value
				this.form.scale=e.detail.value
			},
			async getfetch(id){
				var zhindo=await this.get("/api/organization/"+id)
				console.log("获取到的组织信息",zhindo)
				this.form=zhindo.data.data
				this.jhghggsd=zhindo.data.data.nature
				this.jhghggsdb=zhindo.data.data.scale
			},
			async modify(){
				var xiugai=await this.get("/api/organization",this.form,'PUT')
				console.log("修改信息",xiugai)	
				uni.navigateBack({
					delta:1
				})
}
		},
		onNavigationBarButtonTap() {
			this.modify()			
		},
        mounted() {},
		onLoad(options) {
			this.getfetch(options.id)
			this.id=options.id
			var that = this			
			uni.$on('address',(params)=>{  
				if(params.type == 1){
					this.form.province = params.id
					this.addresss.province =  params.name
				}else if(params.type == 2){
					this.form.city = params.id
					this.addresss.city =  params.name
				}else{
					this.form.area = params.id
					this.addresss.area =  params.name
				}
			})
		},
		onUnload() {
			uni.$off('address')
		},
    }

</script>
<style  scoped>
	.kjnnjxeert{
		position: absolute;
		right: 20upx;
		top: 0upx
	}
</style>
